<html>
<head>
<title>A simple encode for Java and Html Version 1.0.0(Author:Zhenqing Yu,yuzhenqing@hotmail.com)</title>
<script>
function doit() {
  var str = source.value;
  var tmp1 = "";
  var tmp2 = "";
  var tmp3 = "";
  for (var i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) < 128) {
	  tmp1 += str.charAt(i);
	  tmp2 += str.charAt(i);
	  tmp3 += str.charCodeAt(i) + ",";
	}
	else {
	  tmp1 += "&#"+str.charCodeAt(i)+";";
	  tmp2 += "\\u"+(str.charCodeAt(i)).toString(16);
	  tmp3 += str.charCodeAt(i) + ",";
	}
  }
  dest1.value = tmp1;
  dest2.value = tmp2;
  dest3.value = tmp3;
}
function doAntiHtml() {
  var str = dest1.value;
  var tmp1 = "";
  for (var i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) == 10) {
	  tmp1 += "<br/>";
	}
    else if (str.charCodeAt(i) == 13) {
	}
    else if (str.charAt(i) == '<') {
	  tmp1 += "&lt;";
	}
    else if (str.charAt(i) == '>') {
	  tmp1 += "&gt;";
	}
    else {
	  tmp1 += str.charAt(i);
	}
  }
  var  dd = window.open("");
  dd.document.body.innerHTML = tmp1;
}
function doAntiJava() {
  var str = dest2.value;
  var tmp1 = "";
  for (var i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) == 10) {
	  tmp1 += "<br/>";
	}
    else if (str.charCodeAt(i) == 13) {
	}
    else if (str.charAt(i) == '<') {
	  tmp1 += "&lt;";
	}
    else if (str.charAt(i) == '\'') {
	  tmp1 += "\\\'";
	}
    else if (str.charAt(i) == '\\') {
	  if (i < (str.length - 1) && str.charAt(i + 1) != 'u') {
	    tmp1 += "\\\\";
	  }
	  else {
	    tmp1 += "\\";
	  }
	}
    else if (str.charAt(i) == '>') {
	  tmp1 += "&gt;";
	}
    else {
	  tmp1 += str.charAt(i);
	}
  }
  var dd = window.open("");
  dd.document.write("<script>document.write('"+tmp1+"');");
  dd.document.write("<");
  dd.document.write("/script>");
}
</script>
</head>
<body>
Source Data:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<textarea id="source" rows="6" cols="60"></textarea> <input type="button" value="Encode" onclick="doit();"/><br/><br/>

Encode for HTML:<textarea id="dest1" rows="6" cols="60"></textarea></textarea> <input type="button" value="Decode" onclick="doAntiHtml();"/> <br/><br/>
Encode for JAVA Unicode:<textarea id="dest2" rows="6" cols="60"></textarea></textarea> <input type="button" value="Decode" onclick="doAntiJava();"/> <br/><br/>
The unicode value:&nbsp;&nbsp;&nbsp;<textarea id="dest3" rows="6" cols="60"></textarea> <br/><br/>
</body>
</html>